﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class ResourceManager {

    private static Dictionary<int, Sprite> dic_Sprite;
    private static Dictionary<string, AudioClip> dic_Sound;

    static ResourceManager()
    {
        dic_Sprite  = new Dictionary<int, Sprite>();
        Sprite[] spriteArray = Resources.LoadAll<Sprite>("Sprite/2048Atlas");
        for (int i = 0; i < spriteArray.Length; i++)
        {
            dic_Sprite.Add(int.Parse(spriteArray[i].name), spriteArray[i]);
        }

        dic_Sound = new Dictionary<string, AudioClip>();
    }

    //根据数字，加载相应图片
    public static Sprite GetImage(int number)
    {
        if (dic_Sprite.ContainsKey(number))
            return dic_Sprite[number];
        return null;
    }
/*
    public static AudioClip GetSound(string name)
    {
        AudioClip clip = null;
        if (dic_Sound.ContainsKey(name))
            clip = dic_Sound[name];
        else
        {
            clip = Resources.Load<AudioClip>("Sounds/" + name);
            dic_Sound.Add(name, clip);
        }
        return clip;
    }*/
}
